import java.util.concurrent.BlockingQueue;


public class WorkerB implements Runnable {
	private BlockingQueue<Integer> integers;
	private BlockingQueue<String> strings;
	
	int id;
	private String letter;

	public WorkerB(int the_id, BlockingQueue<Integer> the_integers, BlockingQueue<String> the_strings) {
		integers = the_integers;
		strings = the_strings;
		id = the_id;
	}
	
	private void addString() {
		try {
			strings.put(letter);
		} catch(InterruptedException e) { }
	}
	
	private void removeInt() {
		try {
			int number = integers.take();
			letter = String.valueOf(number);
		} catch(InterruptedException e) { }
	}
	
	@Override
	public void run() {
		removeInt();
		//System.err.println("WorkerB " + id + " removed: " + letter);
		addString();
		//System.err.println("WorkerB " + id + " added: " + letter);
	}
}